<?php

abstract class Form_Abstract
{
    public $name;
    
    protected $_cleanData;    
    protected $_rawData;
    protected $_attributes;
    /**
     * @var Filter
     */
    protected $_filter;
    protected $_validator;

    public function __construct ($name, $attributes = array())
    {
        $this->name = $name;
        $this->_attributes = array_merge(array('name' => $name), $attributes);
    }

    /**
     * @return string Html
     */
    public function __toString()
    {
        return $this->render();
    }
    
    public function addValidator($validator){
        $this->_validator = $validator;
    }
    
    public function addFilter($filter){
        $this->_filter = $filter;
    }
    
    public function setValue ($value)
    {
        $this->_rawData = $value;
        $this->_cleanData = $value;
    }
    
    public function getValue ()
    {
        if(is_object($this->_filter)){
            $this->_filter->setData($this->_cleanData);
            $this->_cleanData = $this->_filter->execute();
        }
        return $this->_cleanData;
    }
    
    public function isValid(){

    }
}
?>